package com.sunmnet.auto.spring.mvc.variable.impl;

import com.sunmnet.auto.spring.mvc.baen.FieldSturcture;
import com.sunmnet.auto.spring.mvc.baen.TBStructure;
import com.sunmnet.auto.spring.mvc.temp.FileType;
import com.sunmnet.auto.spring.mvc.variable.IVarDeal;

public class JsDeal implements IVarDeal {
	
	public String excute(FileType type, TBStructure tb) {
		    StringBuilder sb = new StringBuilder();
			for(FieldSturcture field : tb.getFields()){
		         sb.append("  var ").append(field.getPropertyName()).append(" = $")
					.append("('#").append(field.getPropertyName()).append("').")
					.append("val()");
			        sb.append(";\r\n");
			}
			sb.append("  var param").append(" = {");
			for(FieldSturcture field : tb.getFields()){
				sb.append(field.getPropertyName()).append(" : ")
				.append(field.getPropertyName())
				.append(",");
			}
			sb.setLength(sb.length() - 1);
			sb.append("};");
			return sb.toString();
	}
}
